package com.jerry.security.mapper;

import java.util.List;

import com.jerry.security.domain.Permission;
import com.jerry.security.domain.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface UserMapper {

	// 查询用户信息
	@Select("select * from t_user where username = #{userName}")
	User findByUsername(@Param("userName") String userName);

	// 查询用户的权限
	@Select("select permission.* from t_user user " +
			"inner join t_user_role user_role on user.id = user_role.user_id " +
			"inner join t_role_permission role_permission on user_role.role_id = role_permission.role_id " +
			"inner join t_permission permission on role_permission.perm_id = permission.id " +
			"where user.username = #{userName};")
	List<Permission> findPermissionByUsername(@Param("userName") String userName);

}
